﻿using System;
using System.ComponentModel;
using Rio.Framework.Localisation;
using Rio.Framework.Pages.Workflow.Models;

namespace Rio.Flow.Application.Models.Flow
{
    public class AdminDataViewModel : INotifyPropertyChanged
    {
        #region Fields

        private DataItemTreeViewCollection _itemsTreeView;

        #endregion Fields

        #region Constructors

        public AdminDataViewModel()
        {
            this.ItemsTreeView = new DataItemTreeViewCollection(null);
            this.InitTreeModel();
        }

        #endregion Constructors

        #region Events

        public event EventHandler Loaded;

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion Events

        #region Properties

        /// <summary>
        /// Called when [property changed].
        /// </summary>
        /// <param name="P_PropertyName">Name of the p_ property.</param>
        public void OnPropertyChanged(string P_PropertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(P_PropertyName));
            }
        }

        /// <summary>
        /// Gets or sets the items tree view.
        /// </summary>
        /// <value>The items tree view.</value>
        public DataItemTreeViewCollection ItemsTreeView
        {
            get { return _itemsTreeView; }
            set
            {
                _itemsTreeView = value;
                OnPropertyChanged("ItemsTreeView");
            }
        }

        #endregion Properties


        /// <summary>
        /// Inits the tree model.
        /// </summary>
        private void InitTreeModel()
        {
            /*
             * Processing
             */
            DataItemTreeView L_Receipt = new DataItemTreeView();
            L_Receipt.iIdRepertory = (int)Repertory.RECEIPT;
            L_Receipt.SubItemType = WorkflowTreeSubItemType.Processing;
            L_Receipt.ItemType = WorkflowTreeItemType.Send;
            L_Receipt.bIsExpanded = true;
            L_Receipt.sText = Resx.GetLabel(ResxFlowPage.FLOW_WAITING);
            L_Receipt.sImageSrc = "../Assets/Images/flow_processing.png";

            L_Receipt.bIsDropAllowed = false;
            this.ItemsTreeView.Add(L_Receipt);

            /*
             * Completed
             */
            DataItemTreeView L_Send = new DataItemTreeView();
            L_Send.iIdRepertory = (int)Repertory.SEND;
            L_Send.SubItemType = WorkflowTreeSubItemType.Completed;
            L_Send.ItemType = WorkflowTreeItemType.Send;
            L_Send.bIsExpanded = true;
            L_Send.sText = Resx.GetLabel(ResxFlowPage.FLOW_PROCESSED);
            L_Send.sImageSrc = "../Assets/Images/flow_finished.png";
            L_Send.bIsDropAllowed = false;
            this.ItemsTreeView.Add(L_Send);
        }

    }
}
